import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import Classify from '../views/Classify.vue'
import FlashSale from '@/views/FlashSale.vue'
import Login from '@/views/Login.vue'
import Register from '@/views/Register.vue'
import Cart from '@/views/Cart.vue'
import Coupons from '@/views/Coupons.vue'
import MyCoupons from '@/views/MyCoupons.vue'
import Product from '@/views/Product.vue'
import UserCenter from '@/views/UserCenter.vue'
import PurchaseDialog from '@/views/PurchaseDialog.vue'
import Search from '@/views/Search.vue'
import MyOrder from '@/views/MyOrder.vue'
import Login2 from '@/views/Login2.vue'
import Login3 from '@/views/Login3.vue'
import Register2 from '@/views/Register2.vue'
import MerchantLayout from '@/views/MerchantLayout.vue'
import Merchant from '@/views/Merchant.vue'
import Admin from '@/views/Admin.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView,
    },
    {
      path: '/classify',
      name: 'classify',
      component: Classify,
    },
    {
      path: '/flashsale',
      name: 'flashsale',
      component: FlashSale,
    },
    {
      path: '/login',
      name: 'login',
      component: Login
    },
    {
      path: '/register',
      name:'register',
      component: Register,
    },
    {
      path: '/cart',
      name: 'cart',
      component: Cart,
    },
    {
      path: '/coupons',
      name: 'coupons',
      component: Coupons,
    },
    {
      path: '/mycoupons',
      name:'mycoupons',
      component: MyCoupons,
    },
    {
      path: '/product/:id',
      name: 'product',
      component: Product,
      props: true,
    },
    {
      path: '/usercenter',
      name: 'usercenter',
      component: UserCenter,
    },
    {
      path: '/purchasedialog',
      name: 'purchasedialog',
      component: PurchaseDialog,
      props: true,
    },
    {
      path: '/search',
      name:'search',
      component: Search,
    },
    {
      path: '/myorder',
      name:'myorder',
      component: MyOrder,
    },
    {
      path: '/login2',
      name: 'login2',
      component: Login2,
    },
    {
      path: '/login3',
      name: 'login3',
      component: Login3,
    },
    {
      path: '/register2',
      name:'register2',
      component: Register2,
    },
    {
      path: '/merchantlayout',
      name:'merchantlayout',
      component: MerchantLayout,
      children: [
        {
          path: 'add-product',
          name: 'AddProduct',
          component: () => import('@/components/shop/AddProduct.vue')
        },
        {
          path: 'approved',
          name: 'ApprovedProducts',
          component: () => import('@/components/shop/ApprovedProducts.vue')
        },
        {
          path: 'rejected',
          name: 'RejectedProducts',
          component: () => import('@/components/shop/RejectedProducts.vue')
        },
        {
          path: 'pending',
          name: 'PendingProducts',
          component: () => import('@/components/shop/PendingProducts.vue')
        },
        {
          path: '',
          redirect: { name: 'PendingProducts' }
        }
      ]
    },
    {
      path: '/merchant',
      name:'merchant',      
      component: Merchant,
    },
    {
      path: '/admin',
      name: 'admin',      
      component: Admin,
    },
  ],
})

export default router
